import { defineStore } from 'pinia'

export const useEntriesStore = defineStore('entries', {
    state: () => ({
        entries: [
            {
                id: 1,
                name: '孙月莹',
                competition: '大一蓝桥杯',
                fee: 300,
                paymentDate: '2022-12-20',
                status: '已缴费'
            },
            {
                id: 2,
                name: '孙月莹',
                competition: '大三蓝桥杯',
                fee: 300,
                paymentDate: '2024-12-20',
                status: '已缴费'
            },
            {
                id: 3,
                name: '孙月莹',
                competition: '大二传智杯省赛',
                fee: 88,
                paymentDate: '2023-12-20',
                status: '已缴费'
            },
            {
                id: 4,
                name: '孙月莹',
                competition: '大三传智杯省赛',
                fee: 88,
                paymentDate: '2024-12-20',
                status: '已缴费'
            },
            {
                id: 5,
                name: '孙月莹',
                competition: '大三传智杯国赛',
                fee: 88,
                paymentDate: '2025-03-20',
                status: '已缴费'
            },
            {
                id: 6,
                name: '孙月莹',
                competition: '四级',
                fee: 35,
                paymentDate: '2023-03-20',
                status: '已缴费'
            },
            {
                id: 7,
                name: '孙月莹',
                competition: '六级',
                fee: 37,
                paymentDate: '2023-10-20',
                status: '已缴费'
            },
            {
                id: 8,
                name: '孙月莹',
                competition: '六级',
                fee: 37,
                paymentDate: '2024-10-20',
                status: '已缴费'
            },
            {
                id: 9,
                name: '孙月莹',
                competition: '全国大学生英语竞赛',
                fee: 20,
                paymentDate: '2023-04-20',
                status: '已缴费'
            },
            {
                id: 10,
                name: '孙月莹',
                competition: '全国大学生英语竞赛',
                fee: 50,
                paymentDate: '2025-01-20',
                status: '已缴费'
            },
            {
                id: 11,
                name: '孙月莹',
                competition: '软考信息处理技术员',
                fee: 146,
                paymentDate: '2024-01-20',
                status: '已缴费'
            },
            {
                id: 12,
                name: '孙月莹',
                competition: '软考信息系统监理员',
                fee: 146,
                paymentDate: '2025-01-20',
                status: '已缴费'
            },  
            {
                id: 13,
                name: '孙月莹',
                competition: '计算机二级考试',
                fee: 120,
                paymentDate: '2025-01-20',
                status: '已缴费'
            },
            {
                id: 14,
                name: '孙月莹',
                competition: '高中英语教师资格证三科考试',
                fee: 210,
                paymentDate: '2024-12-20',
                status: '已缴费'
            },
            {
                id: 15,
                name: '孙月莹',
                competition: '全国大学生英语阅读大赛',
                fee: 60,
                paymentDate: '2023-12-20',
                status: '已缴费'
            },
            {
                id: 16,
                name: '孙月莹',
                competition: '全国大学生英语词汇大赛',
                fee: 60,
                paymentDate: '2023-01-20',
                status: '已缴费'
            },
            {
                id: 17,
                name: '孙月莹',
                competition: '大美吉林双语推荐管演讲大赛',
                fee: 49,
                paymentDate: '2024-01-20',
                status: '已缴费'
            },
            {
                id: 18,
                name: '孙月莹',
                competition: '中国计算机设计大赛省赛',
                fee: 80,
                paymentDate: '2024-04-20',
                status: '已缴费'
            },
             {
                id: 19,
                name: '孙月莹',
                competition: '全国大学生创新创业大赛',
                fee: 50,
                paymentDate: '2025-04-26',
                status: '已缴费'
            }
        ]
    }),

    actions: {
        addEntry(entry) {
            const newEntry = {
                id: this.entries.length + 1,
                ...entry
            }
            this.entries.push(newEntry)
        },

        updateEntry(entry) {
            const index = this.entries.findIndex(e => e.id === entry.id)
            if (index !== -1) {
                this.entries[index] = entry
            }
        },

        deleteEntry(id) {
            const index = this.entries.findIndex(e => e.id === id)
            if (index !== -1) {
                this.entries.splice(index, 1)
            }
        },

        setEntries(entries) {
            this.entries = entries
        }
    }
}) 